#pragma once

#include <vector>
#include <atomic>
#include "event_loop_thread.h"

namespace rr {
namespace nio {

class EventLoopThreadPool 
{
public:
    using Sptr = std::shared_ptr<EventLoopThreadPool>;

public:
    EventLoopThreadPool(const std::string& name = "");
    ~EventLoopThreadPool();

    int32_t Start(uint32_t num);
    void Stop();

    EventLoopThread::Sptr GetThread(uint32_t index);
    EventLoop::Sptr GetLoopByIndex(uint32_t index);
    EventLoop::Sptr GetNextLoop();

private:
    std::string name_;
    std::vector<EventLoopThread::Sptr> threads_;
    std::atomic<uint32_t>              index_{0};
};


} //namespace 
} //namespace 